package com.xinli.business.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinli.business.domain.LfTopic;
import com.xinli.business.mapper.LfTopicMapper;
import com.xinli.business.service.ILfTopicService;
import com.xinli.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 圈子Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-26
 */
@Service
public class LfTopicServiceImpl extends ServiceImpl<LfTopicMapper, LfTopic>  implements ILfTopicService
{
    @Autowired
    private LfTopicMapper lfTopicMapper;

    /**
     * 查询圈子
     *
     * @param id 圈子主键
     * @return 圈子
     */
    @Override
    public LfTopic selectLfTopicById(Long id)
    {
        return lfTopicMapper.selectLfTopicById(id);
    }

    /**
     * 查询圈子列表
     *
     * @param lfTopic 圈子
     * @return 圈子
     */
    @Override
    public List<LfTopic> selectLfTopicList(LfTopic lfTopic)
    {
        return lfTopicMapper.selectLfTopicList(lfTopic);
    }
    @Override
    public List<Long> getTopicIds(int   cateId   ){
        LfTopic  lfTopic = new LfTopic();
        lfTopic.setCateId(Long.valueOf(cateId));
        List<LfTopic> topics = lfTopicMapper.selectLfTopicList(lfTopic);
        List<Long> topicIds = topics.stream().map(item->item.getId()).collect(Collectors.toList());
        return topicIds;
    }

    /**
     * 新增圈子
     *
     * @param lfTopic 圈子
     * @return 结果
     */
    @Override
    public int insertLfTopic(LfTopic lfTopic)
    {
                lfTopic.setCreateTime(DateUtils.getNowDate());
            return lfTopicMapper.insertLfTopic(lfTopic);
    }

    /**
     * 修改圈子
     *
     * @param lfTopic 圈子
     * @return 结果
     */
    @Override
    public int updateLfTopic(LfTopic lfTopic)
    {
        return lfTopicMapper.updateLfTopic(lfTopic);
    }

    /**
     * 批量删除圈子
     *
     * @param ids 需要删除的圈子主键
     * @return 结果
     */
    @Override
    public int deleteLfTopicByIds(Long[] ids)
    {
        return lfTopicMapper.deleteLfTopicByIds(ids);
    }

    /**
     * 删除圈子信息
     *
     * @param id 圈子主键
     * @return 结果
     */
    @Override
    public int deleteLfTopicById(Long id)
    {
        return lfTopicMapper.deleteLfTopicById(id);
    }
}
